.EXPORT_ALL_VARIABLES:

CLI_FILENAME = evcpe

prefix =/usr
exec_prefix =${prefix}
libdir =${exec_prefix}/lib
sharedlibdir =${libdir}
includedir =${prefix}/include

LIB_CFLAGS  = $(CFLAGS) -shared -fPIC
LIB_LDFLAGS = $(LDFLAGS) -Wl,-soname,$(LIB_FILENAME).$(LIB_VERMAJOR).$(LIB_VERMINOR)

CLI_CFLAGS  = $(CFLAGS)
CLI_LDFLAGS = $(LDFLAGS)

EVCPE = evcpe
EV = event

PROC_MODULES_LIB += $(ROOTFS_DIR)/lib/libtds_ext.so
PROC_MODULES_LIB += $(ROOTFS_DIR)/lib/libcommon.so

INCLUDES = -I. -Icompat -I $(EV)/include -I ${EV} -I${EV}/compat/sys -I./triams/include
ECFLAGS = -DSTART_BY_CONFIG_FILE_TRI=1 -fPIC -Wall -g -O0 ${INCLUDES}

ifeq ($(INFORM_TYPE),INFORM_BOOT_DELAY)
	ECFLAGS += -DTGP_EVCPE_INFORM_BOOT_DELAY
endif

ECFLAGS += -DTGP_FORBIT_ACC_FR_BROWSER=$(TGP_FORBIT_ACC_FR_BROWSER)

EVENT_LIB += -lssl -lcrypto -ldl -rdynamic -lrt -lpthread -lcfg -ltds_ext -lmxml -lnvram -lm

SRCS = session.c minixml.c log.c util.c handler.c class.c obj.c cpe.c dns_cache.c \
    event_list.c param_name_list.c param_value_list.c access_list.c \
    param_attr_list.c set_param_attr_list.c method_list.c \
    xml.c data_xml.c msg.c response.c xml_stack.c \
    xmlns.c inform.c get_rpc_methods.c get_param_values.c set_param_values.c \
    get_param_attrs.c set_param_attrs.c \
    add_object.c delete_object.c fault.c class_xml.c \
    obj_xml.c attr.c obj_list.c type.c attr_schema.c constraint.c url.c \
    msg_xml.c attr_xml.c method.c cookie.c inform_xml.c \
    get_rpc_methods_xml.c param_info_list.c get_param_names.c fault_xml.c \
    persister.c add_object_xml.c get_param_names_xml.c \
    get_param_values_xml.c set_param_value_list.c set_param_values_xml.c \
    accessor.c reboot.c schedule_inform.c delete_object_xml.c base64.c md5.c \
    digcalc.c auth.c data_action.c mibTr069.c \
    download.c upload.c transfer_complete.c transfer.c \
    download_xml.c upload_xml.c transfer_complete_xml.c openssl_hostname_validation.c hostcheck.c tr111.c

SRCS += $(EV)/buffer.c
SRCS += $(EV)/bufferevent.c
SRCS += $(EV)/bufferevent_filter.c
SRCS += $(EV)/bufferevent_pair.c
SRCS += $(EV)/bufferevent_ratelim.c
SRCS += $(EV)/bufferevent_sock.c
SRCS += $(EV)/bufferevent_openssl.c
SRCS += $(EV)/epoll.c
SRCS += $(EV)/evdns.c
SRCS += $(EV)/event.c
SRCS += $(EV)/event_tagging.c
SRCS += $(EV)/evmap.c
SRCS += $(EV)/evrpc.c
SRCS += $(EV)/evthread.c
SRCS += $(EV)/evutil.c
SRCS += $(EV)/evutil_time.c
SRCS += $(EV)/evutil_rand.c
SRCS += $(EV)/http.c
SRCS += $(EV)/listener.c
SRCS += $(EV)/log.c
SRCS += $(EV)/poll.c
SRCS += $(EV)/select.c
SRCS += $(EV)/signal.c
SRCS += triams/include/sha256.c



OBJS = $(patsubst %.c,%.o,$(SRCS))

EVCPE_SRCS = evcpe.c
EVCPE_OBJS = $(patsubst %.c,%.o,$(EVCPE_SRCS))

all: ${OBJS} ${EVCPE_OBJS}
	$(CC) -o ${EVCPE} ${LDFLAGS}  ${OBJS} ${EVCPE_OBJS} ${EVENT_LIB}  $(PROC_MODULES_LIB)
	
%.o: %.c $(wildcard *.h)
	    $(CC) ${ECFLAGS} -c $< -o $@
	
install:
		

clean:
	@rm -f *.o $(EV)/*.o $(EVCPE)
